home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Text / Emacs-1.12d folder / lisp / mac / dumptime.el < prev    next >
Encoding:
Text File  |  1993-12-30  |  2.9 KB  |  86 lines  |  [TEXT/EMAC]

  1. ;;;
  2. ;;; This file is part of a Macintosh port of GNU Emacs.
  3. ;;; Copyright (C) 1993 Marc Parmet.  All rights reserved.
  4. ;;;
  5. ;;; The following files are included in the dump.
  6. ;;;
  7. ;;; Any file that includes a call to AEInstallEventHandler or menu traps must not be
  8. ;;; included in a dump, but instead be executed at each startup.
  9. ;;;
  10.  
  11. (load "mac/headers")
  12. (load "mac/traps")
  13. (load "mac/clipboard")
  14. (load "mac/mouse")
  15.  
  16. (autoload 'ispell "ispell" nil t)
  17. (autoload 'ispell-word "ispell" nil t)
  18. (define-key esc-map "$" 'ispell-word)
  19.  
  20. ;;; We redefine this function to make it stationery-aware.
  21.  
  22. (defun find-file-noselect (filename &optional nowarn)
  23.   "Read file FILENAME into a buffer and return the buffer.
  24. If a buffer exists visiting FILENAME, return that one,
  25. but verify that the file has not changed since visited or saved.
  26. The buffer is not selected, just returned to the caller."
  27.   (setq filename (expand-file-name filename))
  28.   ;; Get rid of the prefixes added by the automounter.
  29.   (if (and (string-match automount-dir-prefix filename)
  30.            (file-exists-p (file-name-directory
  31.                            (substring filename (1- (match-end 0))))))
  32.       (setq filename (substring filename (1- (match-end 0)))))
  33.   (if (file-directory-p filename)
  34.       (if find-file-run-dired
  35.           (dired-noselect filename)
  36.         (error "%s is a directory." filename))
  37.     (let ((buf (get-file-buffer filename))
  38.           error)
  39.       (if buf
  40.           (or nowarn
  41.               (verify-visited-file-modtime buf)
  42.               (cond ((not (file-exists-p filename))
  43.                      (error "File %s no longer exists!" filename))
  44.                     ((yes-or-no-p
  45.                       (if (buffer-modified-p buf)
  46.                           "File has changed since last visited or saved.  Flush your changes? "
  47.                         "File has changed since last visited or saved.  Read from disk? "))
  48.                      (save-excursion
  49.                        (set-buffer buf)
  50.                        (revert-buffer t t)))))
  51.         (save-excursion
  52.           ;;; Added
  53.           (let* ((spec (make-string sizeof-FSSpec 0))
  54.                  (err (unix-filename-to-FSSpec filename spec))
  55.                  (have-stationery (and (zerop err) (ae-is-stationery spec))))
  56.             
  57.             (setq buf (if have-stationery
  58.                           (generate-new-buffer "untitled")
  59.                         (create-file-buffer filename)))
  60.             (set-buffer buf)
  61.             (erase-buffer)
  62.             (condition-case ()
  63.                 (insert-file-contents filename (not have-stationery))
  64.               (file-error
  65.                (setq error t)
  66.                ;; Run find-file-not-found-hooks until one returns non-nil.
  67.                (let ((hooks find-file-not-found-hooks))
  68.                  (while (and hooks
  69.                              (not (funcall (car hooks))))
  70.                    (setq hooks (cdr hooks))))))
  71.             (setq default-directory (file-name-directory filename))
  72.             (funcall
  73.              (if have-stationery (function stationery-after-find-file)
  74.                (function after-find-file))
  75.              error (not nowarn)))))
  76.       buf)))
  77.  
  78. (defun stationery-after-find-file (&optional error warn)
  79.   (setq buffer-read-only nil)
  80.   (if noninteractive
  81.       nil
  82.     (if auto-save-default
  83.         (auto-save-mode t)))
  84.   (set-buffer-modified-p nil)
  85.   (mapcar 'funcall find-file-hooks))
  86.